<?php
/**
 * This file is part of Hyperf Mall.
 *
 * @link     https://gitee.com/scwlkj/hyperf_mall
 * @contact  hyperf_mall@163.com
 */

namespace App\JsonRpc;

use App\Exception\BaseException;
use App\Repository\OrderRepository;
use Hyperf\RpcServer\Annotation\RpcService;
use App\JsonRpc\Interfaces\OrderServiceInterface;

/**
 * @RpcService(name="Orders::OrderService", protocol="jsonrpc", server="jsonrpc")
 */
class OrderService extends BaseService implements OrderServiceInterface
{

    public function init()
    {
        $this->repository = OrderRepository::getInstance();
    }


    /**
     * Notes: c端会员订单列表
     * Author: Bruce.z
     * DateTime: 2022/7/14 9:07
     * @param array $condition
     * @param int $page
     * @param int $size
     * @return array
     */
    public function appIndex(array $condition, int $page, int $size):array
    {
        return OrderRepository::getInstance()->appIndex($condition, $page, $size);
    }

    /**
     * Notes: A端支付信息
     * Author: Bruce.z
     * DateTime: 2022/7/14 11:07
     * @param $oid
     * @return array
     */
    public function info($oid) :array
    {
        return OrderRepository::getInstance()->info($oid);
    }

    /**
     * Notes: cancel
     * Author: Bruce.z
     * DateTime: 2022/7/15 14:25
     * @param $oid
     * @return bool
     */
    public function cancel($oid): bool
    {
        return OrderRepository::getInstance()->cancel($oid);
    }

    /**
     * Notes: c端 获取订单详情
     * Author: Bruce.z
     * DateTime: 2022/7/15 15:29
     * @param $oid
     * @return array
     */
    public function appDetail($oid):array
    {
        return OrderRepository::getInstance()->appDetail($oid);
    }

    /**
     * Notes: 会员中心首页统计
     * Author: Bruce.z
     * DateTime: 2022/7/19 14:41
     * @param int $member_id
     * @return array
     */
    public function appMemberIndex(int $member_id):array
    {
        return $this->repository->appMemberIndex($member_id);
    }

    /**
     * Notes: 直接下单
     * Author: Bruce.z
     * DateTime: 2022/7/22 10:02
     * @param array $data
     * @return array
     */
    public function buy(array $data):array
    {
        return $this->repository->buy($data);
    }

    /**
     * Notes:A端订单列表
     * Author: Bruce.z
     * DateTime: 2022/8/9 9:59
     * @param array $condition
     * @param int $page
     * @param int $size
     * @return array
     */
    public function list(array $condition, int $page, int $size): array
    {
        return $this->repository->list($condition, $page, $size);
    }

    /**
     * Notes: A 端订单详情
     * Author: Bruce.z
     * DateTime: 2022/8/10 15:23
     * @param $oid
     * @return array
     */
    public function orderDetail($oid):array
    {
        return $this->repository->orderDetail($oid);
    }

    /**
     * Note:发货
     * Author:Jurij.cao
     * Date:2022/8/11
     * @param $param
     * @return bool
     */
    public function delivery($param):bool
    {
        return $this->repository->delivery($param);
    }

    /**
     * Notes: 管理员支付
     * Author: Bruce.z
     * DateTime: 2022/8/11 16:33
     * @param $oid
     * @return bool
     */
    public function payed($oid):bool
    {
        return $this->repository->payed($oid);
    }


    /**
     * Note:确认收货
     * Author:Jurij.cao
     * Date:2022/8/12
     * @param $oid
     * @return bool
     * @return bool
     * @throws BaseException
     */
    public function confirmGoods($oid):bool
    {
        return $this->repository->confirmGoods($oid);
    }
}
